<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="../asserts/dist/vue.js"></script>
		<script src="../asserts/dist/layui.js"></script>
		<script src="../asserts/js/jquery-2.1.1.min.js"></script>
		<link rel="stylesheet" type="text/css" href="../asserts/dist/css/layui.css" />
	</head>
	<body style="background-color: #C9C9C9;">
		<div id="app" style="padding-top: 10%; padding-left: 30%;">
			<div style="background-color: white; margin-right: 50%; margin-left: 10%; padding: 3%;padding-right: 8%;">
				<form class="layui-form" >
					<iframe style="display: none" id="rfFrame"  name="rfFrame" src="about:blank"></iframe>
				  <div class="layui-form-item">
				    <label class="layui-form-label">账号</label>
				    <div class="layui-input-block">
				      <input type="text" name="username" required  lay-verify="required" placeholder="请输入账号" autocomplete="off" class="layui-input" v-model="username">
				    </div>
				  </div>
				  <div class="layui-form-item">
				    <label class="layui-form-label">密码</label>
				    <div class="layui-input-block">
				      <input type="password" name="password" required  lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input" v-model="password">
				    </div>
				  </div>
				  <div class="layui-form-item">
				    <div class="layui-input-block">
						<button class="layui-btn" lay-submit lay-filter="formDemo" id="submit" @click="sub()">立即提交</button>
				      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
				    </div>
				  </div>
				</form>
			</div>
		</div>
		
	</body>
	<script>
		document.forms[0].target="rfFrame";
		var vueData = new Vue({
			el: '#app',
			data: function() {
				return {
					username:'',
					password:''
				}
			},
			created() {

			},
			methods: {
				sub(){
					if (this.username != null && this.username != '' && this.password != null && this.password != ''){
						var _this = this;
						$.ajax({
							url: "/taobei_web/admin/login",
							data: {"username":_this.username,
								"password":_this.password
							},
							type: "GET",
							dataType: "json",
							success: function(res) {
								console.log(res)
								if (res.status == 200) {
									window.sessionStorage.setItem("admin",res.data)
									window.location.href="index.html"
								}else {
									layui.use('layer', function() {
										undefined
										var layer = layui.layer;
										layer.msg("账号或密码错误", {
											time: 2000,
										});
									});
								}
							}
						});
					}
				}
			}

		});
	</script>
</html>
